﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package pbjAS {
    import flash.utils.*;
    import pbjAS.params.*;
    import pbjAS.regs.*;
    import pbjAS.consts.*;
    import pbjAS.ops.*;

    public class PBJAssembler {

        private static function writeOp(_arg1:int, _arg2:PBJReg, _arg3:PBJReg, _arg4:ByteArray):void{
            _arg4.writeByte(_arg1);
            _arg4.writeShort(regCode(_arg2));
            var _local5:Array = _arg2.data;
            var _local6:Array = _arg3.data;
            var _local7:int = destMask(_local5);
            var _local8:int = (((_local5)==null) ? 4 : _local5.length - 1);
            if (((!((_local6 == null))) && ((_local6.length == 1)))){
                switch (_local6[0]){
                    case PBJChannel.M2x2:
                        _local8 = 4;
                        break;
                    case PBJChannel.M3x3:
                        _local8 = 8;
                        break;
                    case PBJChannel.M4x4:
                        _local8 = 12;
                        break;
                };
            };
            _arg4.writeByte(((_local7 << 4) | _local8));
            _arg4.writeShort(regCode(_arg3));
            _arg4.writeByte(srcSwizzle(_local6, ((_local6 == null)) ? 4 : _local6.length));
            _arg4.writeByte(0);
        }
        private static function regCode(_arg1:PBJReg):int{
            if ((_arg1 is RFloat)){
                return (_arg1.value);
            };
            if ((_arg1 is RInt)){
                return ((_arg1.value + 0x8000));
            };
            return (NaN);
        }
        private static function writeFloat(_arg1:Number, _arg2:ByteArray):void{
            _arg2.endian = Endian.BIG_ENDIAN;
            _arg2.writeFloat(_arg1);
            _arg2.endian = Endian.LITTLE_ENDIAN;
        }
        private static function writeSrc(_arg1:PBJReg, _arg2:int, _arg3:ByteArray):void{
            _arg3.writeShort(regCode(_arg1));
            _arg3.writeByte(srcSwizzle(_arg1.data, _arg2));
        }
        private static function assert(_arg1:Object, _arg2:Object):void{
            if (_arg1 != _arg2){
                throw (new Error(((("Assert " + _arg1) + " != ") + _arg2)));
            };
        }
        private static function writeDest(_arg1:PBJReg, _arg2:int, _arg3:ByteArray):void{
            var _local4:int = destMask(_arg1.data);
            _arg3.writeShort(regCode(_arg1));
            _arg3.writeByte(((_local4 << 4) | _arg2));
        }
        private static function writeMeta(_arg1:PBJMeta, _arg2:ByteArray):void{
            var _local3:String = PBJTools.getValueType(_arg1.value);
            _arg2.writeByte(getTypeCode(_local3));
            _arg2.writeUTFBytes(_arg1.key);
            _arg2.writeByte(0);
            writeValue(_arg1.value, _arg2);
        }
        private static function getSizeBits(_arg1:String):int{
            switch (_arg1){
                case PBJType.TFloat:
                case PBJType.TInt:
                    return (0);
                case PBJType.TFloat2:
                case PBJType.TInt2:
                    return (1);
                case PBJType.TFloat3:
                case PBJType.TInt3:
                    return (2);
                case PBJType.TFloat4:
                case PBJType.TInt4:
                    return (3);
            };
            return (0);
        }
        private static function destMask(_arg1:Array):int{
            var _local3:String;
            if (_arg1 == null){
                return (15);
            };
            var _local2:int;
            for each (_local3 in _arg1) {
                switch (_local3){
                    case PBJChannel.R:
                        if (_local2 != 0){
                            throw (new Error("Can't swizzle dest reg"));
                        };
                        _local2 = (_local2 | 8);
                        break;
                    case PBJChannel.G:
                        if ((_local2 & !((7 == 0)))){
                            throw (new Error("Can't swizzle dest reg"));
                        };
                        _local2 = (_local2 | 4);
                        break;
                    case PBJChannel.B:
                        if ((_local2 & !((3 == 0)))){
                            throw (new Error("Can't swizzle dest reg"));
                        };
                        _local2 = (_local2 | 2);
                        break;
                    case PBJChannel.A:
                        if ((_local2 & !((1 == 0)))){
                            throw (new Error("Can't swizzle dest reg"));
                        };
                        _local2 = (_local2 | 1);
                        break;
                    case PBJChannel.M4x4:
                    case PBJChannel.M3x3:
                    case PBJChannel.M2x2:
                        return (0);
                };
            };
            return (_local2);
        }
        public static function assemble(_arg1:PBJ):ByteArray{
            var _local3:PBJMeta;
            var _local4:PBJParam;
            var _local5:PBJOpcode;
            var _local6:PBJMeta;
            var _local7:Array;
            var _local2:ByteArray = new ByteArray();
            _local2.endian = Endian.LITTLE_ENDIAN;
            _local2.writeByte(165);
            _local2.writeUnsignedInt(_arg1.version);
            _local2.writeByte(164);
            _local2.writeShort(_arg1.name.length);
            _local2.writeUTFBytes(_arg1.name);
            for each (_local3 in _arg1.metadatas) {
                _local2.writeByte(160);
                writeMeta(_local3, _local2);
            };
            for each (_local4 in _arg1.parameters) {
                if ((_local4.parameter is Parameter)){
                    _local2.writeByte(161);
                    _local2.writeByte(((_local4.parameter as Parameter).out) ? 2 : 1);
                    _local2.writeByte(getTypeCode((_local4.parameter as Parameter).type));
                    _local2.writeShort(regCode((_local4.parameter as Parameter).reg));
                    if (((((_local4.parameter as Parameter).reg is RInt)) || (((_local4.parameter as Parameter).reg is RFloat)))){
                        _local7 = (_local4.parameter as Parameter).reg.data;
                    };
                    switch ((_local4.parameter as Parameter).type){
                        case PBJType.TFloat2x2:
                            assert(_local7, null);
                            _local2.writeByte(2);
                            break;
                        case PBJType.TFloat3x3:
                            assert(_local7, null);
                            _local2.writeByte(3);
                            break;
                        case PBJType.TFloat4x4:
                            assert(_local7, null);
                            _local2.writeByte(4);
                            break;
                        default:
                            _local2.writeByte(destMask(_local7));
                    };
                } else {
                    if ((_local4.parameter is Texture)){
                        _local2.writeByte(163);
                        _local2.writeByte((_local4.parameter as Texture).index);
                        _local2.writeByte((_local4.parameter as Texture).channels);
                    };
                };
                _local2.writeUTFBytes(_local4.name);
                _local2.writeByte(0);
                for each (_local6 in _local4.metadatas) {
                    _local2.writeByte(162);
                    writeMeta(_local6, _local2);
                };
            };
            for each (_local5 in _arg1.code) {
                writeCode(_local5, _local2);
            };
            return (_local2);
        }
        private static function writeCode(_arg1:Object, _arg2:ByteArray):void{
            if ((_arg1 is OpNop)){
                _arg2.writeByte(0);
                _arg2.writeInt(0);
                _arg2.writeShort(0);
                _arg2.writeByte(0);
            } else {
                if ((_arg1 is OpAdd)){
                    writeOp(1, _arg1.dst, _arg1.src, _arg2);
                } else {
                    if ((_arg1 is OpSub)){
                        writeOp(2, _arg1.dst, _arg1.src, _arg2);
                    } else {
                        if ((_arg1 is OpMul)){
                            writeOp(3, _arg1.dst, _arg1.src, _arg2);
                        } else {
                            if ((_arg1 is OpRcp)){
                                writeOp(4, _arg1.dst, _arg1.src, _arg2);
                            } else {
                                if ((_arg1 is OpDiv)){
                                    writeOp(5, _arg1.dst, _arg1.src, _arg2);
                                } else {
                                    if ((_arg1 is OpATan2)){
                                        writeOp(6, _arg1.dst, _arg1.src, _arg2);
                                    } else {
                                        if ((_arg1 is OpPow)){
                                            writeOp(7, _arg1.dst, _arg1.src, _arg2);
                                        } else {
                                            if ((_arg1 is OpMod)){
                                                writeOp(8, _arg1.dst, _arg1.src, _arg2);
                                            } else {
                                                if ((_arg1 is OpMin)){
                                                    writeOp(9, _arg1.dst, _arg1.src, _arg2);
                                                } else {
                                                    if ((_arg1 is OpMax)){
                                                        writeOp(10, _arg1.dst, _arg1.src, _arg2);
                                                    } else {
                                                        if ((_arg1 is OpStep)){
                                                            writeOp(11, _arg1.dst, _arg1.src, _arg2);
                                                        } else {
                                                            if ((_arg1 is OpSin)){
                                                                writeOp(12, _arg1.dst, _arg1.src, _arg2);
                                                            } else {
                                                                if ((_arg1 is OpCos)){
                                                                    writeOp(13, _arg1.dst, _arg1.src, _arg2);
                                                                } else {
                                                                    if ((_arg1 is OpTan)){
                                                                        writeOp(14, _arg1.dst, _arg1.src, _arg2);
                                                                    } else {
                                                                        if ((_arg1 is OpASin)){
                                                                            writeOp(15, _arg1.dst, _arg1.src, _arg2);
                                                                        } else {
                                                                            if ((_arg1 is OpACos)){
                                                                                writeOp(16, _arg1.dst, _arg1.src, _arg2);
                                                                            } else {
                                                                                if ((_arg1 is OpATan)){
                                                                                    writeOp(17, _arg1.dst, _arg1.src, _arg2);
                                                                                } else {
                                                                                    if ((_arg1 is OpExp)){
                                                                                        writeOp(18, _arg1.dst, _arg1.src, _arg2);
                                                                                    } else {
                                                                                        if ((_arg1 is OpExp2)){
                                                                                            writeOp(19, _arg1.dst, _arg1.src, _arg2);
                                                                                        } else {
                                                                                            if ((_arg1 is OpLog)){
                                                                                                writeOp(20, _arg1.dst, _arg1.src, _arg2);
                                                                                            } else {
                                                                                                if ((_arg1 is OpLog2)){
                                                                                                    writeOp(21, _arg1.dst, _arg1.src, _arg2);
                                                                                                } else {
                                                                                                    if ((_arg1 is OpSqrt)){
                                                                                                        writeOp(22, _arg1.dst, _arg1.src, _arg2);
                                                                                                    } else {
                                                                                                        if ((_arg1 is OpRSqrt)){
                                                                                                            writeOp(23, _arg1.dst, _arg1.src, _arg2);
                                                                                                        } else {
                                                                                                            if ((_arg1 is OpAbs)){
                                                                                                                writeOp(24, _arg1.dst, _arg1.src, _arg2);
                                                                                                            } else {
                                                                                                                if ((_arg1 is OpSign)){
                                                                                                                    writeOp(25, _arg1.dst, _arg1.src, _arg2);
                                                                                                                } else {
                                                                                                                    if ((_arg1 is OpFloor)){
                                                                                                                        writeOp(26, _arg1.dst, _arg1.src, _arg2);
                                                                                                                    } else {
                                                                                                                        if ((_arg1 is OpCeil)){
                                                                                                                            writeOp(27, _arg1.dst, _arg1.src, _arg2);
                                                                                                                        } else {
                                                                                                                            if ((_arg1 is OpFract)){
                                                                                                                                writeOp(28, _arg1.dst, _arg1.src, _arg2);
                                                                                                                            } else {
                                                                                                                                if ((_arg1 is OpMov)){
                                                                                                                                    writeOp(29, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                } else {
                                                                                                                                    if ((_arg1 is OpFloatToInt)){
                                                                                                                                        writeOp(30, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                    } else {
                                                                                                                                        if ((_arg1 is OpIntToFloat)){
                                                                                                                                            writeOp(31, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                        } else {
                                                                                                                                            if ((_arg1 is OpMatrixMatrixMult)){
                                                                                                                                                writeOp(32, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                            } else {
                                                                                                                                                if ((_arg1 is OpVectorMatrixMult)){
                                                                                                                                                    writeOp(33, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                } else {
                                                                                                                                                    if ((_arg1 is OpMatrixVectorMult)){
                                                                                                                                                        writeOp(34, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                    } else {
                                                                                                                                                        if ((_arg1 is OpNormalize)){
                                                                                                                                                            writeOp(35, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                        } else {
                                                                                                                                                            if ((_arg1 is OpLength)){
                                                                                                                                                                writeOp(36, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                            } else {
                                                                                                                                                                if ((_arg1 is OpDistance)){
                                                                                                                                                                    writeOp(37, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                } else {
                                                                                                                                                                    if ((_arg1 is OpDotProduct)){
                                                                                                                                                                        writeOp(38, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                    } else {
                                                                                                                                                                        if ((_arg1 is OpCrossProduct)){
                                                                                                                                                                            writeOp(39, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                        } else {
                                                                                                                                                                            if ((_arg1 is OpEqual)){
                                                                                                                                                                                writeOp(40, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                            } else {
                                                                                                                                                                                if ((_arg1 is OpNotEqual)){
                                                                                                                                                                                    writeOp(41, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                                } else {
                                                                                                                                                                                    if ((_arg1 is OpLessThan)){
                                                                                                                                                                                        writeOp(42, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                                    } else {
                                                                                                                                                                                        if ((_arg1 is OpLessThanEqual)){
                                                                                                                                                                                            writeOp(43, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                                        } else {
                                                                                                                                                                                            if ((_arg1 is OpLogicalNot)){
                                                                                                                                                                                                writeOp(44, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                                            } else {
                                                                                                                                                                                                if ((_arg1 is OpLogicalAnd)){
                                                                                                                                                                                                    writeOp(45, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                                                } else {
                                                                                                                                                                                                    if ((_arg1 is OpLogicalOr)){
                                                                                                                                                                                                        writeOp(46, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                                                    } else {
                                                                                                                                                                                                        if ((_arg1 is OpLogicalXor)){
                                                                                                                                                                                                            writeOp(47, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                                                        } else {
                                                                                                                                                                                                            if ((_arg1 is OpSampleNearest)){
                                                                                                                                                                                                                _arg2.writeByte(48);
                                                                                                                                                                                                                writeDest(_arg1.dst, 1, _arg2);
                                                                                                                                                                                                                writeSrc(_arg1.src, 2, _arg2);
                                                                                                                                                                                                                _arg2.writeByte(_arg1.srcTexture);
                                                                                                                                                                                                            } else {
                                                                                                                                                                                                                if ((_arg1 is OpSampleLinear)){
                                                                                                                                                                                                                    _arg2.writeByte(49);
                                                                                                                                                                                                                    writeDest(_arg1.dst, 1, _arg2);
                                                                                                                                                                                                                    writeSrc(_arg1.src, 2, _arg2);
                                                                                                                                                                                                                    _arg2.writeByte(_arg1.srcTexture);
                                                                                                                                                                                                                } else {
                                                                                                                                                                                                                    if ((_arg1 is OpLoadInt)){
                                                                                                                                                                                                                        _arg2.writeByte(50);
                                                                                                                                                                                                                        writeDest(_arg1.reg, 0, _arg2);
                                                                                                                                                                                                                        _arg2.writeInt(_arg1.v);
                                                                                                                                                                                                                    } else {
                                                                                                                                                                                                                        if ((_arg1 is OpLoadFloat)){
                                                                                                                                                                                                                            _arg2.writeByte(50);
                                                                                                                                                                                                                            writeDest(_arg1.reg, 0, _arg2);
                                                                                                                                                                                                                            writeFloat(_arg1.v, _arg2);
                                                                                                                                                                                                                        } else {
                                                                                                                                                                                                                            if ((_arg1 is OpIf)){
                                                                                                                                                                                                                                _arg2.writeByte(52);
                                                                                                                                                                                                                                _arg2.writeShort(0);
                                                                                                                                                                                                                                _arg2.writeByte(0);
                                                                                                                                                                                                                                writeSrc(_arg1.cond, 1, _arg2);
                                                                                                                                                                                                                                _arg2.writeByte(0);
                                                                                                                                                                                                                            } else {
                                                                                                                                                                                                                                if ((_arg1 is OpElse)){
                                                                                                                                                                                                                                    _arg2.writeByte(53);
                                                                                                                                                                                                                                    _arg2.writeInt(0);
                                                                                                                                                                                                                                    _arg2.writeShort(0);
                                                                                                                                                                                                                                    _arg2.writeByte(0);
                                                                                                                                                                                                                                } else {
                                                                                                                                                                                                                                    if ((_arg1 is OpEndIf)){
                                                                                                                                                                                                                                        _arg2.writeByte(54);
                                                                                                                                                                                                                                        _arg2.writeInt(0);
                                                                                                                                                                                                                                        _arg2.writeShort(0);
                                                                                                                                                                                                                                        _arg2.writeByte(0);
                                                                                                                                                                                                                                    } else {
                                                                                                                                                                                                                                        if ((_arg1 is OpFloatToBool)){
                                                                                                                                                                                                                                            writeOp(55, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                                                                                        } else {
                                                                                                                                                                                                                                            if ((_arg1 is OpBoolToFloat)){
                                                                                                                                                                                                                                                writeOp(56, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                                                                                            } else {
                                                                                                                                                                                                                                                if ((_arg1 is OpIntToBool)){
                                                                                                                                                                                                                                                    writeOp(57, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                                                                                                } else {
                                                                                                                                                                                                                                                    if ((_arg1 is OpBoolToInt)){
                                                                                                                                                                                                                                                        writeOp(58, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                                                                                                    } else {
                                                                                                                                                                                                                                                        if ((_arg1 is OpVectorEqual)){
                                                                                                                                                                                                                                                            writeOp(59, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                                                                                                        } else {
                                                                                                                                                                                                                                                            if ((_arg1 is OpVectorNotEqual)){
                                                                                                                                                                                                                                                                writeOp(60, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                                                                                                            } else {
                                                                                                                                                                                                                                                                if ((_arg1 is OpBoolAny)){
                                                                                                                                                                                                                                                                    writeOp(61, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                                                                                                                } else {
                                                                                                                                                                                                                                                                    if ((_arg1 is OpBoolAll)){
                                                                                                                                                                                                                                                                        writeOp(62, _arg1.dst, _arg1.src, _arg2);
                                                                                                                                                                                                                                                                    };
                                                                                                                                                                                                                                                                };
                                                                                                                                                                                                                                                            };
                                                                                                                                                                                                                                                        };
                                                                                                                                                                                                                                                    };
                                                                                                                                                                                                                                                };
                                                                                                                                                                                                                                            };
                                                                                                                                                                                                                                        };
                                                                                                                                                                                                                                    };
                                                                                                                                                                                                                                };
                                                                                                                                                                                                                            };
                                                                                                                                                                                                                        };
                                                                                                                                                                                                                    };
                                                                                                                                                                                                                };
                                                                                                                                                                                                            };
                                                                                                                                                                                                        };
                                                                                                                                                                                                    };
                                                                                                                                                                                                };
                                                                                                                                                                                            };
                                                                                                                                                                                        };
                                                                                                                                                                                    };
                                                                                                                                                                                };
                                                                                                                                                                            };
                                                                                                                                                                        };
                                                                                                                                                                    };
                                                                                                                                                                };
                                                                                                                                                            };
                                                                                                                                                        };
                                                                                                                                                    };
                                                                                                                                                };
                                                                                                                                            };
                                                                                                                                        };
                                                                                                                                    };
                                                                                                                                };
                                                                                                                            };
                                                                                                                        };
                                                                                                                    };
                                                                                                                };
                                                                                                            };
                                                                                                        };
                                                                                                    };
                                                                                                };
                                                                                            };
                                                                                        };
                                                                                    };
                                                                                };
                                                                            };
                                                                        };
                                                                    };
                                                                };
                                                            };
                                                        };
                                                    };
                                                };
                                            };
                                        };
                                    };
                                };
                            };
                        };
                    };
                };
            };
        }
        private static function getMatrixBits(_arg1:String):int{
            switch (_arg1){
                case PBJType.TFloat2x2:
                    return (1);
                case PBJType.TFloat3x3:
                    return (2);
                case PBJType.TFloat4x4:
                    return (3);
            };
            return (0);
        }
        private static function writeValue(_arg1:Object, _arg2:ByteArray):void{
            var _local3:Number;
            var _local4:Number;
            var _local5:Number;
            if ((_arg1 is PFloat)){
                writeFloat(_arg1.f, _arg2);
            } else {
                if ((_arg1 is PFloat2)){
                    writeFloat(_arg1.f1, _arg2);
                    writeFloat(_arg1.f2, _arg2);
                } else {
                    if ((_arg1 is PFloat3)){
                        writeFloat(_arg1.f1, _arg2);
                        writeFloat(_arg1.f2, _arg2);
                        writeFloat(_arg1.f3, _arg2);
                    } else {
                        if ((_arg1 is PFloat4)){
                            writeFloat(_arg1.f1, _arg2);
                            writeFloat(_arg1.f2, _arg2);
                            writeFloat(_arg1.f3, _arg2);
                            writeFloat(_arg1.f4, _arg2);
                        } else {
                            if ((_arg1 is PFloat2x2)){
                                assert(_arg1.a.length, 4);
                                for each (_local3 in _arg1.a) {
                                    writeFloat(_local3, _arg2);
                                };
                            } else {
                                if ((_arg1 is PFloat3x3)){
                                    assert(_arg1.a.length, 9);
                                    for each (_local4 in _arg1.a) {
                                        writeFloat(_local4, _arg2);
                                    };
                                } else {
                                    if ((_arg1 is PFloat4x4)){
                                        assert(_arg1.a.length, 16);
                                        for each (_local5 in _arg1.a) {
                                            writeFloat(_local5, _arg2);
                                        };
                                    } else {
                                        if ((_arg1 is PInt)){
                                            _arg2.writeShort(_arg1.i);
                                        } else {
                                            if ((_arg1 is PInt2)){
                                                _arg2.writeShort(_arg1.i1);
                                                _arg2.writeShort(_arg1.i2);
                                            } else {
                                                if ((_arg1 is PInt3)){
                                                    _arg2.writeShort(_arg1.i1);
                                                    _arg2.writeShort(_arg1.i2);
                                                    _arg2.writeShort(_arg1.i3);
                                                } else {
                                                    if ((_arg1 is PInt4)){
                                                        _arg2.writeShort(_arg1.i1);
                                                        _arg2.writeShort(_arg1.i2);
                                                        _arg2.writeShort(_arg1.i3);
                                                        _arg2.writeShort(_arg1.i4);
                                                    } else {
                                                        if ((_arg1 is PString)){
                                                            _arg2.writeUTFBytes(_arg1.s);
                                                            _arg2.writeByte(0);
                                                        };
                                                    };
                                                };
                                            };
                                        };
                                    };
                                };
                            };
                        };
                    };
                };
            };
        }
        private static function srcSwizzle(_arg1:Array, _arg2:int):int{
            var _local4:String;
            if (_arg1 == null){
                return (27);
            };
            var _local3:int;
            for each (_local4 in _arg1) {
                _local3 = (_local3 << 2);
                switch (_local4){
                    case PBJChannel.G:
                        _local3 = (_local3 | 1);
                        break;
                    case PBJChannel.B:
                        _local3 = (_local3 | 2);
                        break;
                    case PBJChannel.A:
                        _local3 = (_local3 | 3);
                        break;
                    case PBJChannel.M4x4:
                    case PBJChannel.M3x3:
                    case PBJChannel.M2x2:
                        return (0);
                };
            };
            return ((_local3 << ((4 - _arg2) * 2)));
        }
        private static function getTypeCode(_arg1:String):int{
            switch (_arg1){
                case PBJType.TFloat:
                    return (1);
                case PBJType.TFloat2:
                    return (2);
                case PBJType.TFloat3:
                    return (3);
                case PBJType.TFloat4:
                    return (4);
                case PBJType.TFloat2x2:
                    return (5);
                case PBJType.TFloat3x3:
                    return (6);
                case PBJType.TFloat4x4:
                    return (7);
                case PBJType.TInt:
                    return (8);
                case PBJType.TInt2:
                    return (9);
                case PBJType.TInt3:
                    return (10);
                case PBJType.TInt4:
                    return (11);
                case PBJType.TString:
                    return (12);
            };
            return (NaN);
        }

    }
}//package pbjAS 
